package com.alibaba.nacos.naming.pojo;


import com.alibaba.fastjson.JSON;
import io.micrometer.core.instrument.util.JsonUtils;

public class ServiceInfoLog {
    /**
     * 服务名
     */
    private String serviceName;

    /**
     * 请求url
     */
    private String url;

    /**
     * 请求IP地址
     */
    private String ip;

    /**
     * 切入点方法
     */
    private String classMethod;

    /**
     * 请求入参
     */
    private String param;

    /**
     * 调用时长
     */
    private double longTime;

    /**
     * 响应编码
     */
    private int status;

    /**
     * 是否异常
     */
    private int exceptionFlag;

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getClassMethod() {
        return classMethod;
    }

    public void setClassMethod(String classMethod) {
        this.classMethod = classMethod;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public double getLongTime() {
        return longTime;
    }

    public void setLongTime(double longTime) {
        this.longTime = longTime;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getExceptionFlag() {
        return exceptionFlag;
    }

    public void setExceptionFlag(int exceptionFlag) {
        this.exceptionFlag = exceptionFlag;
    }

    public ServiceInfoLog(){

    }

    public ServiceInfoLog(String serviceName, String url, String ip, String classMethod, String param, double longTime, int status) {
        this.serviceName = serviceName;
        this.url = url;
        this.ip = ip;
        this.classMethod = classMethod;
        this.param = param;
        this.longTime = longTime;
        this.status = status;
        this.exceptionFlag = status == 200? 0:1;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
